//
//  AbstractParsingDirector.m
//  MokoAPP
//
//  Created by 현식 강 on 11. 8. 26..
//  Copyright 2011 아이온. All rights reserved.
//

#import "ParsingDirector.h"
#import "SeekoParser.h"
#import "SeekoHTMLParser.h"
#import "SeekoJSONParser.h"
#import "MokoAppDelegate.h"
#import "BoardListAllVO.h"
#import "ArticleAndCommentVO.h"
@implementation ParsingDirector
@synthesize responseData, key, parserDic;
-(void)dealloc {
    [parserDic release];
    [key release];
    [responseData release];
    [super dealloc];
}
+(ParsingDirector*)sharedParsingDirector {
    static ParsingDirector* instance = nil;
    if( instance == nil ) {
        @synchronized(self) {
            if( instance == nil ) {
                instance = [[ParsingDirector alloc] init];
                instance.parserDic = [[[NSDictionary alloc] initWithObjectsAndKeys:[SeekoHTMLParser sharedSeekoHTMLParser], @"HTML", [SeekoJSONParser sharedSeekoJSONParser], @"JSON", nil] autorelease];
                // 바뀔 예정
                instance.key = @"HTML";
            }
        }
    }
    return instance;
}
-(SeekoParser*)getParser {
    SeekoParser* parser = [parserDic objectForKey:key];
    NSString* responseStr = [[NSString alloc] initWithData:responseData encoding:EUC_KR];
    NSString* responseStr1 = [responseStr stringByReplacingOccurrencesOfString:@"" withString:@" "];
    parser.responseString = responseStr1;
    
    [responseStr release];
    return parser;
}
-(NSArray*)getMenu {
    return [[self getParser] getMenu];
}
-(BoardListAllVO*)getArticleList {
    return [[self getParser] getArticleList];
}
-(void)memberInfo {
    [[self getParser] memberInfo];
}
-(ArticleAndCommentVO*)getArticleAndComment {
    return [[self getParser] getArticleAndComment];
}
-(NSString*)getError {
    return [[self getParser] getError];
}
-(MemoListAllVO*)getMemoList {
    return [[self getParser] getMemoList];
}
-(BOOL)getMemoWriteResult {
    return [[self getParser] getMemoWriteResult];
}
-(MemoArticleVO*)getMemoArticle {
    return [[self getParser] getMemoArticle]; 
}
@end
